package com.dbapp.shopping.data;

import com.dbapp.shopping.domain.GoodOwner;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import com.dbapp.shopping.domain.Good;
import com.dbapp.shopping.domain.User;

import java.lang.Iterable;
import java.util.List;
import java.util.Optional;

public interface GoodOwnerRepository
    extends CrudRepository<GoodOwner, Long> {

    @Query("select g from GoodOwner g where user = ?1 and good.display = true")
    List<GoodOwner> findGoodsByUser(User user);

    Optional<GoodOwner> findByGood(Good good);
}
